<template>
  <div class="box">
    <div class="ZhanBi" ref="redContainer"></div>
    <div class="title"><b>商品销售占比</b></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "XiaoshouZhanbi",
  props: {
    xData: {
      type: Array,
      required: true,
    },
    yData: {
      type: Array,
      required: true,
    },
  },
  components: {},
  data() {
    return {
      chart: null,
      option: {
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 15, name: "小明" },
              { value: 20, name: "小红" },
              { value: 32, name: "小刘" },
              { value: 28, name: "小张" },
              { value: 5, name: "小可" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      },
    };
  },
  mounted() {
    this.chart = echarts.init(this.$refs.redContainer);
    this.chart.setOption(this.option);
  },
};
</script>

<style scoped lang="scss">
.box {
  width: 100%;
  height: 100%;
  position: relative;
}
.ZhanBi {
  background-color: rgb(255, 255, 255);
  width: 100%;
  height: 100%;
  position: absolute;
}
.title {
  position: absolute;
  z-index: 1;
  left: 370px;
  top: 23px;
  font-size: 20px;
}
</style>
